Skip to content

fix: Array.mapIndexes stops on false literal#7441

Open
ElectricalBoy wants to merge 3 commits intomainfrom
mapIndexes-handle-literal-false
Open

fix: Array.mapIndexes stops on false literal#7441
ElectricalBoy wants to merge 3 commits intomainfrom
mapIndexes-handle-literal-false

Conversation

@ElectricalBoy
Copy link
Copy Markdown
Collaborator

Summary

--[[
Returns the array {funct(1), funct(2), funct(3), ...}. Stops before the first nil value returned by funct.
Example:
Array.mapIndexes(function(x) return x < 5 and x * x or nil end)
-- returns {1, 4, 9, 16}
]]

The documentation for Array.mapIndexes specifies that it stops before the first nil returned by funct. This is not true as the current implementation could also stop on a false literal being returned.

This fixes the forementioned problem by explicitly checking for non-nil return from funct.

How did you test this change?

included test

@Rathoz
Copy link
Copy Markdown
Collaborator

Rathoz commented May 4, 2026

Can you skim through and see if there's any usage that needs to be updated? I rather not have an infinite loop on our hands

@ElectricalBoy
Copy link
Copy Markdown
Collaborator Author

Can you skim through and see if there's any usage that needs to be updated?

all usages are okay from what I can tell

@ElectricalBoy ElectricalBoy requested a review from Rathoz May 6, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants